/**
 * 使用 TS 的方式, 给组件的 props 标注类型
 */

import React, { type ReactElement } from "react";

interface Props {
  a?: string;
  b?: string;
  c?: string;
  name: string;
  children?: ReactElement;
}

class Hello extends React.Component<Props> {
  static defaultProps = {
    a: "张三",
  };

  render() {
    console.log("this.props", this.props);
    const { name } = this.props;

    return (
      <div>
        <p>
          Hello, {name} - {this.props.a}
        </p>
        <button
          onClick={() => {
            this.props.name = "王五";
          }}
        >
          按钮
        </button>
      </div>
    );
  }
}

export default Hello;
